#include <bits/stdc++.h>
#define double long double
using namespace std;
int n, m, x, y;
double f[50005], a[1005][1005];
void gauss(int n){
for(int i = 1; i < n; i++){
if(i < n) a[i][i + 1] /= a[i][i];
a[i][i - 1] /= a[i][i], a[i][n + 1] /= a[i][i], a[i][i] = 1;
a[i + 1][n + 1] -= a[i][n + 1] * a[i + 1][i], a[i + 1][i + 1] -= a[i][i + 1] * a[i + 1][i], a[i + 1][i] = 0;
}
f[n] = a[n][n + 1] / a[n][n];
for(int i = n - 1; i >= 1; i--)
a[i][n + 1] -= a[i][i + 1] * f[i + 1], f[i] = a[i][n + 1];
}
int main(){
cin >> n >> m >> x >> y, n = n - x + 1;
if(m == 1) return cout << (n - 1) * 2, 0;
for(int i = 1; i < n; i++){
a[1][1] = 2, a[1][2] = -1, a[1][m + 1] = f[1] + 3;
a[m][m] = 2, a[m][m - 1] = -1, a[m][m + 1] = f[m] + 3;
for(int j = 2; j < m; j++)
a[j][j] = 3, a[j][j - 1] = a[j][j + 1] = -1, a[j][m + 1] = f[j] + 4;
gauss(m);
}
printf("%.12Lf", f[y]);
return 0;
}
80A - Panoramix's Prediction | 1354B - Ternary String |
122B - Lucky Substring | 266B - Queue at the School |
1490A - Dense Array | 1650B - DIV + MOD |
1549B - Gregor and the Pawn Game | 553A - Kyoya and Colored Balls |
1364A - XXXXX | 1499B - Binary Removals |
1569C - Jury Meeting | 108A - Palindromic Times |
46A - Ball Game | 114A - Cifera |
776A - A Serial Killer | 25B - Phone numbers |
1633C - Kill the Monster | 1611A - Make Even |
1030B - Vasya and Cornfield | 1631A - Min Max Swap |
1296B - Food Buying | 133A - HQ9+ |
1650D - Twist the Permutation | 1209A - Paint the Numbers |
1234A - Equalize Prices Again | 1613A - Long Comparison |
1624B - Make AP | 660B - Seating On Bus |
405A - Gravity Flip | 499B - Lecture |